﻿<UserControl xmlns:PageBar="clr-namespace:Mengsk.ProxyDelivery.App.UI.PageBar"  x:Class="Mengsk.ProxyDelivery.App.UI.Order.ReturnProcessUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xmlns:myui="clr-namespace:Mengsk.ProxyDelivery.App.UI.Order"
                xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             d:DesignHeight="300" d:DesignWidth="1400" Loaded="UserControl_Loaded">

    <UserControl.Resources>
        <Style x:Key="ImageButton" TargetType="Button" BasedOn="{StaticResource TextButton}">
            <EventSetter Event="Click" Handler="GoodsImage_Click"/>
        </Style>
        <Style x:Key="OrderChangeStyle" TargetType="{x:Type ListBoxItem}">
            <Setter Property="Margin" Value="1,0,1,3"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">

                        <GroupBox Margin="0" Padding="0">
                            <GroupBox.Header>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="退换编号:" Margin="3" VerticalAlignment="Center"/>
                                    <TextBox Text="{Binding OrderChange.Id}" Margin="3" VerticalAlignment="Center" Width="60" Style="{StaticResource SelectableTextBox}"/>
                                    <TextBlock Text="订单编号：" Margin="3" VerticalAlignment="Center" />
                                    <TextBox Text="{Binding Order.Id}" Margin="3" VerticalAlignment="Center" Width="100" Style="{StaticResource SelectableTextBox}"/>
                                    <TextBlock Text="卖家编号：" Margin="3" VerticalAlignment="Center"/>
                                    <TextBox Style="{StaticResource SelectableTextBox}" Text="{Binding OrderChange.SellerId}" Margin="3" VerticalAlignment="Center" Width="100"/>
                                    <TextBlock Text="申请类型：" Margin="3" VerticalAlignment="Center"/>
                                    <TextBlock Text="{Binding OrderChange.Type,Converter={StaticResource descriptionConverter}}" Margin="3" VerticalAlignment="Center" Width="80"/>
                                    <TextBlock Text="创建时间：" Margin="3" VerticalAlignment="Center"/>
                                    <TextBlock Text="{Binding OrderChange.CreateTime,Converter={StaticResource datetimeConverter}}" Width="130" VerticalAlignment="Center"/>
                                    <Button Content="删除" Style="{StaticResource TextButton}" DataContext="{Binding}" Name="btnDelete"  Click="btnDelete_Click" VerticalAlignment="Center"/>
                                </StackPanel>
                            </GroupBox.Header>

                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Grid Grid.Row="0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Button BorderBrush="White" Grid.Row="0" Grid.Column="0" Grid.RowSpan="3" BorderThickness="0" Tag="{Binding OrderGoods.NumberId}" Style="{StaticResource ImageButton}">
                                        <Image Source="{Binding OrderGoods.Image,Converter={StaticResource webUrlImageConverter}}" Margin="3" Height="60" Width="60" Stretch="Fill" Tag="{Binding OrderGoods.NumberId}"/>
                                    </Button>
                                    <StackPanel Grid.Column="1" Orientation="Vertical" Width="200" HorizontalAlignment="Center">
                                        <StackPanel  Orientation="Horizontal">
                                            <TextBox Text="{Binding GoodsInfo,Mode=OneWay}" Style="{StaticResource SelectableTextBox}" VerticalAlignment="Center"/>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox Text="{Binding GoodsStock,Mode=OneWay}" Style="{ StaticResource SelectableTextBox}"/>
                                        </StackPanel>

                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="退款编号:" Margin="3"/>
                                            <TextBox Text="{Binding OrderChange.SystemRefundId}" Style="{StaticResource SelectableTextBox}" Margin="3"/>
                                        </StackPanel>

                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="新订单编号:" Margin="3"/>
                                            <TextBox Text="{Binding OrderChange.NewOrderId}" Style="{StaticResource SelectableTextBox}" Margin="3"/>
                                        </StackPanel>
                                    </StackPanel>
                                    <TextBlock VerticalAlignment="Top" Grid.Column="2" HorizontalAlignment="Center" Text="{Binding Price}" Width="100"/>
                                    <TextBlock Grid.Column="3" VerticalAlignment="Top" HorizontalAlignment="Center"  Text="{Binding Count}" Width="100"/>
                                    <StackPanel Grid.Column="5" Orientation="Vertical" Width="150">
                                        <TextBlock Text="返回物流" Margin="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                        <TextBlock Text="{Binding OrderChange.ReturnDeliveryCompany}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                        <Button Content="{Binding OrderChange.ReturnDeliveryNumber}" Style="{StaticResource TextButton}" VerticalAlignment="Center" HorizontalAlignment="Center" Name="btnQueryDelivery" Click="btnQueryDelivery_Click"/>
                                        <Button Name="btnModify" Content="修改" Width="60" Margin="3" VerticalAlignment="Center" HorizontalAlignment="Center" Click="btnModify_Click" DataContext="{Binding}"/>
                                    </StackPanel>

                                    <StackPanel Grid.Column="6" Orientation="Vertical" Width="150">
                                        <TextBlock Text="接收信息" Margin="3" VerticalAlignment="Center"/>
                                        <TextBlock Text="{Binding OrderChange.ReciveTime,Converter={StaticResource datetimeConverter}}" Margin="3" VerticalAlignment="Center"/>
                                        <TextBlock Text="{Binding OrderChange.ReciveOperator}" Margin="3" VerticalAlignment="Center"/>
                                    </StackPanel>

                                    <StackPanel Grid.Column="7" Orientation="Vertical" Width="150">
                                        <TextBlock Text="处理信息" Margin="3" VerticalAlignment="Center"/>
                                        <TextBlock Text="{Binding OrderChange.ProcessTime,Converter={StaticResource datetimeConverter}}" Margin="3" VerticalAlignment="Center"/>
                                        <TextBlock Text="{Binding OrderChange.ProcessOperator}" Margin="3" VerticalAlignment="Center"/>
                                    </StackPanel>

                                    <StackPanel Grid.Column="8" Orientation="Vertical" Width="80">
                                        <TextBlock Text="运费退款" Margin="3" VerticalAlignment="Center"/>
                                        <TextBlock Text="{Binding OrderChange.RefundDeliveryMoney}" Margin="3" VerticalAlignment="Center"/>
                                    </StackPanel>

                                    <StackPanel Grid.Column="9" Orientation="Vertical" Width="80">
                                        <TextBlock Text="运费补款" Margin="3" VerticalAlignment="Center"/>
                                        <TextBlock Text="{Binding OrderChange.MoreRefundDeliveryMoney}" Margin="3" VerticalAlignment="Center"/>
                                    </StackPanel>

                                    <StackPanel Grid.Column="10" Orientation="Vertical" Width="80">
                                        <TextBlock Text="{Binding OrderChange.State,Converter={StaticResource descriptionConverter}}" HorizontalAlignment="Center"/>
                                        <Button Content="详情" Width="60" DataContext="{Binding}" Name="btnDetail" Click="btnDetail_Click" Margin="3" VerticalAlignment="Center"/>
                                        <Button Content="拒绝" Width="60" DataContext="{Binding}" Name="btnReject" Click="btnReject_Click" Margin="3" VerticalAlignment="Center"/>
                                    </StackPanel>

                                    <StackPanel Grid.Column="12" Orientation="Vertical" Width="100">
                                        <Button Content="处理" Width="60" DataContext="{Binding}" Click="btnProcessEx_Click" Name="btnProcessEx" HorizontalAlignment="Center" Visibility="Visible"/>
                                        <Button Content="打印" Width="60" DataContext="{Binding}" Name="btnPrintInfo" Click="btnPrintInfo_Click" HorizontalAlignment="Center" Visibility="Visible"/>
                                        <Button Content="退款" Width="60" DataContext="{Binding}" Name="btnRefund" Click="btnRefund_Click" HorizontalAlignment="Center" />
                                    </StackPanel>
                                </Grid>
                                <Line Grid.Row="1" Stroke="LightGray" StrokeThickness="1" Stretch="Fill" X1="0" Y1="0" X2="10" Y2="0"/>
                                <StackPanel Orientation="Horizontal" Grid.Row="2"  >
                                    <TextBlock Text="{Binding Order.ReceiverName}" Margin="3" VerticalAlignment="Center"/>
                                    <TextBlock Text=" " Margin="3" VerticalAlignment="Center"/>
                                    <TextBlock Text="{Binding Order.ReceiverPhone}" Margin="3" VerticalAlignment="Center"/>
                                    <TextBlock Text=" " Margin="3" VerticalAlignment="Center"/>
                                    <TextBlock Text="{Binding Order.ReceiverMobile}" Margin="3" VerticalAlignment="Center"/>
                                    <TextBlock Text=" " Margin="3" VerticalAlignment="Center"/>
                                    <TextBlock Text="{Binding Order.ReceiverAddress}" Margin="3" VerticalAlignment="Center"/>
                                </StackPanel>
                                <Line Grid.Row="3" Stroke="LightGray" StrokeThickness="1" Stretch="Fill" X1="0" Y1="0" X2="10" Y2="0"/>
                                <Grid Grid.Row="4">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0" Text="卖家备注:" Margin="3" VerticalAlignment="Center"/>
                                    <TextBox Grid.Column="1" Text="{Binding OrderChange.SellerComment}" Margin="3" VerticalAlignment="Center" Style="{StaticResource SelectableTextBox}"/>
                                    <Button Grid.Column="2" Name="btnViewSellerImage" Background="{Binding OrderChange,Converter={StaticResource orderChangeImageColorConverter},ConverterParameter=SellerImage}" Content="{Binding OrderChange,Converter={StaticResource orderChangeImageCountConverter},ConverterParameter=SellerImage}" Margin="3" VerticalAlignment="Center" Width="80" Click="btnViewSellerImage_Click"/>
                                </Grid>
                                <Line Grid.Row="5"  Stroke="LightGray" StrokeThickness="1" Stretch="Fill" X1="0" Y1="0" X2="10" Y2="0"/>
                                <Grid Grid.Row="6">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0" Text="系统备注:" Margin="3" VerticalAlignment="Center"/>
                                    <TextBox Grid.Column="1" Text="{Binding OrderChange.SystemComment}" Margin="3" VerticalAlignment="Center" Style="{StaticResource SelectableTextBox}"/>
                                    <Button Grid.Column="2" Name="btnViewSystemImage" Background="{Binding OrderChange,Converter={StaticResource orderChangeImageColorConverter}}" Content="{Binding OrderChange,Converter={StaticResource orderChangeImageCountConverter}}" Margin="3" VerticalAlignment="Center" Width="80" Click="btnViewSystemImage_Click"/>
                                </Grid>
                            </Grid>

                        </GroupBox>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Row="0" Grid.Column="0" Text="退货编号:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Grid.Row="0" Grid.Column="1" Name="tbId" Margin="3" VerticalAlignment="Center"/>
            <TextBlock Grid.Row="0" Grid.Column="2" Text="订单编号:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Grid.Row="0" Grid.Column="3" Name="tbOrderId" Margin="3" VerticalAlignment="Center"/>
            <TextBlock Grid.Row="0" Grid.Column="4" Text="卖家编号:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Grid.Row="0" Grid.Column="5" Name="tbSellerId" Margin="3" VerticalAlignment="Center"/>
            <TextBlock Grid.Row="0" Grid.Column="6" Text="货号:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Grid.Row="0" Grid.Column="7" Name="tbNumber" VerticalAlignment="Center" Margin="3"/>
            <TextBlock Grid.Row="0" Grid.Column="8" Text="颜色:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Grid.Row="0" Grid.Column="9" Name="tbColor" Margin="3" VerticalAlignment="Center"/>
            <TextBlock Grid.Row="0" Grid.Column="10" Text="尺码:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Grid.Row="0" Grid.Column="11" Name="tbSize" Margin="3" VerticalAlignment="Center"/>

            <TextBlock Grid.Row="1" Text="时间类型：" Margin="3" VerticalAlignment="Center"/>
            <ComboBox Grid.Row="1" Grid.Column="1" Name="cbbTimeType" Margin="3" VerticalAlignment="Center">
                <ComboBoxItem>创建时间</ComboBoxItem>
                <ComboBoxItem>接收时间</ComboBoxItem>
                <ComboBoxItem>处理时间</ComboBoxItem>
                <ComboBoxItem>出单时间</ComboBoxItem>
                <ComboBoxItem>回单时间</ComboBoxItem>
                <ComboBoxItem>退款时间</ComboBoxItem>
                <ComboBoxItem>完成时间</ComboBoxItem>
            </ComboBox>
            <TextBlock Grid.Row="1" Grid.Column="2" Text="开始时间：" Margin="3" VerticalAlignment="Center"/>
            <xctk:DateTimePicker Grid.Row="1" Grid.Column="3" Name="dpStartTime" Margin="3" VerticalAlignment="Center"/>
            <TextBlock Grid.Row="1" Grid.Column="4" Text="结束时间：" Margin="3" VerticalAlignment="Center"/>
            <xctk:DateTimePicker Grid.Row="1" Grid.Column="5" Name="dpEndTime" Margin="3" VerticalAlignment="Center"/>
            <TextBlock Grid.Row="1" Grid.Column="6" Text="退货状态:" Margin="3" VerticalAlignment="Center"/>
            <ComboBox Grid.Row="1" Grid.Column="7" Name="cbbStates" Margin="3" VerticalAlignment="Center"/>
            <TextBlock Grid.Row="1" Grid.Column="8" Text="退货类型:" Margin="3" VerticalAlignment="Center"/>
            <ComboBox Grid.Row="1" Grid.Column="9" Name="cbbTypes" Margin="3" VerticalAlignment="Center"/>
            <TextBlock Grid.Row="1" Grid.Column="10" Text="返回单号:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Grid.Row="1" Grid.Column="11" Name="tbReturnDeliveryNumber" Margin="3" VerticalAlignment="Center"/>
        </Grid>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock Name="lbQueryResult" Grid.Column="0" Text="查询结果" Margin="3" VerticalAlignment="Center"/>
            <Button Name="btnQuery" Grid.Column="2" Content="查询" Margin="3" Width="101" Click="btnQuery_Click"/>
            <Button Name="btnCreateWithoutOrder" Grid.Column="3" Content="创建无单退货" Margin="3" VerticalAlignment="Center" Width="101" Click="btnCreateWithoutOrder_Click"/>
            <Button Name="btnPrint" Grid.Column="4" Content="手动打印" Margin="3" VerticalAlignment="Center" Width="100" Click="btnPrint_Click"/>
            <Button Name="btnExport" Grid.Column="5" Content="导出信息" Margin="3" VerticalAlignment="Center" Width="100" Click="btnExport_Click"/>
        </Grid>

        <ListBox Grid.Row="2" Name="lstOrderChanges" ScrollViewer.CanContentScroll="False" ItemContainerStyle="{StaticResource ResourceKey=OrderChangeStyle}" >
        </ListBox>
        <PageBar:PageBarUserControl Grid.Row="3" x:Name="pbBar" PageSize="30" PageChanging="pbBar_PageChanging" />
    </Grid>
</UserControl>
